#include "sys.h"

/**
 * @brief : Print out the MCU model and compiler related information
 * @param : None
 * @return: None
 * @author: bagy
 */
static void CompileInfo_Output(void)
{
	log_i("\r\n");
	log_i("******************* Compile_Info_Output Start ******************************\r\n");
	log_i("* MCU Type      : %s\r\n"      , MCU_MODULE_TYPE);
	log_i("* Date          : %s\r\n"      , __DATE__);
	log_i("* Time          : %s\r\n"      , __TIME__);
	log_i("* File          : %s\r\n"      , __FILE__);
	log_i("* Line          : %d\r\n"      , __LINE__);
	log_i("* Function      : %s\r\n"      , __func__);
	log_i("* Build Time    : %s  %s\r\n"  , __DATE__, __TIME__);
	log_i("* ISO Standard  : %d\r\n"      , __STDC__);
	log_i("* C99 Compiler  : %d\r\n"      , __STDC_VERSION__);
	log_i("*********************** Data Type Byte *************************************\r\n");
	log_i("* long long int : %02d\r\n"    , sizeof(long long int));
	log_i("* short int     : %02d\r\n"    , sizeof(short int));
	log_i("* long int      : %02d\r\n"    , sizeof(long int));
	log_i("* double        : %02d\r\n"    , sizeof(double));
	log_i("* float         : %02d\r\n"    , sizeof(float));
	log_i("* char          : %02d\r\n"    , sizeof(char));
	log_i("* int           : %02d\r\n"    , sizeof(int));
	log_i("******************* Compile_Info_Output Over *******************************\r\n\r\n");
}

/**
 * @brief  Enable peripheral clock.
 * @param  None.
 * @return None.
 * @author bagy
 */
static void rcc_config(void)
{
    rcu_deinit();

    rcu_periph_clock_enable(RCU_GPIOA);

    rcu_periph_clock_enable(RCU_USART0);

    log_i("<%s> rcc config complete.\r\n", __FUNCTION__);
}

/**
 * @brief  System config.
 * @param  None.
 * @return None.
 * @author bagy
 */
void system_config(void)
{
    nvic_priority_group_set(NVIC_PRIGROUP_PRE4_SUB0);

    CompileInfo_Output();

    systick_config();

    rcc_config();

    log_i("<%s> system peripherals config complete. start task scheduler.\r\n", __FUNCTION__);
}

/**
 * @brief  FreeRTOS stack overflow hook function.
 * @param  None.
 * @return None.
 * @author bagy
 */
void vApplicationStackOverflowHook(TaskHandle_t xTask, char* pcTaskName)
{
    log_e("stack overflow\r\n");
}


